import { RootState } from '../types'
import { userSlice } from './slices/userSlice'
import { searchSlice } from './slices/searchSlice'
import { alertSlice } from './slices/alertSlice'
import { paginationSlice } from './slices/paginationSlice'
import { cartSlice } from './slices/cartSlice'

export const selectAccessToken = (state: RootState) =>
	state[userSlice.name].token
export const selectUser = (state: RootState) => state[userSlice.name].data

export const selectCatalogMaxPage = (state: RootState) =>
	state[paginationSlice.name].catalogPagination.maxPage
export const selectCatalogPage = (state: RootState) =>
	state[paginationSlice.name].catalogPagination.selectedPage

export const selectSearch = (state: RootState) => state[searchSlice.name].search

export const selectAlertType = (state: RootState) => state[alertSlice.name].type
export const selectAlertIsOpen = (state: RootState) =>
	state[alertSlice.name].isOpen
export const selectAlertText = (state: RootState) => state[alertSlice.name].text

export const selectCartProducts = (state: RootState) =>
	state[cartSlice.name].products
